//
//  MXMineHomeListCell.m
//  HNBaseProject
//
//  Created by xujie on 2024/6/12.
//

#import "MXMineHomeListCell.h"

@implementation MXMineHomeListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

- (void)createUI {
    self.selectionStyle = 0;
    self.backgroundColor = [UIColor colorWithHexString:@"#F6F7F9"];
    
    self.bgView = [[UIView alloc] initWithFrame:CGRectMake(16, 18, kScreenW-32, 65)];
    self.bgView.backgroundColor = [UIColor whiteColor];
    self.bgView.layer.cornerRadius = 15;
    self.bgView.layer.masksToBounds = YES;
    [self.contentView addSubview:self.bgView];
    
    self.icon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_list_icon"]];
    [self.bgView addSubview:self.icon];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(24);
        make.left.offset(24);
        make.centerY.mas_equalTo(self.bgView);
    }];
    
    self.nameLab = [[UILabel alloc] init];
    [self.bgView addSubview:self.nameLab];
    self.nameLab.textColor = [UIColor colorWithHexString:@"#000000"];
    self.nameLab.font = PFRFontMedium(14);
    [self.nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.icon.mas_right).offset(12);
        make.centerY.mas_equalTo(self.bgView);
    }];
    
    self.countLab = [[UILabel alloc] init];
    [self.bgView addSubview:self.countLab];
    self.countLab.textColor = [UIColor colorWithHexString:@"#3278F6"];
    self.countLab.font = PFRFontMedium(11);
    [self.countLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.offset(-24);
        make.centerY.mas_equalTo(self.bgView);
        make.left.equalTo(self.nameLab.mas_right).offset(15);
    }];
    [self.countLab setPriorityRequired];
    
}

- (void)reloadCellWithModel:(MXHomeModel *)model {
    self.nameLab.text = model.familyName;
    self.countLab.text = [NSString stringWithFormat:@"成员：%ld",model.familyMemberList.count];
}

@end
